import config from "@/config"
import http from "@/utils/request"

export default {
	pager: {
		url: `${config.API_URL}/admin/v1/salary/pager`,
		name: "分页列表",
		get: function (params) {
			return http.get(this.url, params);
		}
	},
	create: {
		url: `${config.API_URL}/admin/v1/salary/create`,
		name: "新增",
		post: function (data) {
			return http.post(this.url, data);
		}
	},
	detail: {
		url: `${config.API_URL}/admin/v1/salary/:id/detail`,
		name: "详情",
		get: function (id) {
			const uri = this.url.replace(':id', id);
			return http.get(uri);
		},
		delete: function (id) {
			const uri = this.url.replace(':id', id);
			return http.delete(uri);
		}
	},
	batch: {
		url: `${config.API_URL}/admin/v1/salary/batch`,
		name: "批量导入",
		post: function (data) {
			return http.post(this.url, data);
		}
	},
	template: {
		url: `${config.API_URL}/admin/setup/salary-template`,
		name: "导入模板",
		get: function () {
			return http.get(this.url);
		},
	},
	auditing: {
		url: `${config.API_URL}/admin/v1/salary/auditing`,
		name: "批量审核",
		post: function (data) {
			return http.post(this.url, data);
		}
	},
	tax: {
		url: `${config.API_URL}/admin/v1/salary/tax`,
		name: "计算个税",
		post: function (data) {
			return http.post(this.url, data);
		}
	},
	multiple: {
		url: `${config.API_URL}/admin/v1/salary/multiple`,
		name: "重复薪资",
		post: function (data) {
			return http.post(this.url, data);
		}
	},
	exports: {
		url: `${config.API_URL}/admin/v1/salary/exports`,
		name: "一键导出",
		post: function (data) {
			return http.post(this.url, data);
		}
	},

	/**
	 * 薪资汇总
	 */
	statistic: {
		pager: {
			url: `${config.API_URL}/admin/v1/salary/statistic/pager`,
			name: "分页列表",
			get: function (params) {
				return http.get(this.url, params);
			}
		}
	},

	/**
	 * 历史导入记录
	 */
	import: {
		pager: {
			url: `${config.API_URL}/admin/v1/salary/import/pager`,
			name: "分页列表",
			get: function (params) {
				return http.get(this.url, params);
			}
		},
		detail: {
			url: `${config.API_URL}/admin/v1/salary/import/:hash/detail`,
			name: "详情",
			delete: function (hash) {
				const url = this.url.replace(':hash', hash);
				return http.delete(url);
			}
		},
	}
}